package org.xcorpio.thread;
class MyThread3 extends Thread {
    public MyThread3(String name) {
        super(name);
    }
    @Override
    public void run() {
        synchronized(this) {
        	for (int i = 0; i < 5; i++) {
                System.out.println(Thread.currentThread().getName() + " loop " + i);  
            }
        }  
    }
}
public class Demo1_2 {
    public static void main(String[] args) {  
        Thread t1 = new MyThread3("t1");  // 新建“线程t1”
        Thread t2 = new MyThread3("t2");  // 新建“线程t2”
        t1.start();                          // 启动“线程t1”
        t2.start();                          // 启动“线程t2” 
    } 
}